package com.heima.search.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.search.dtos.HistorySearchDto;
import com.heima.model.search.dtos.UserSearchDto;
import com.heima.search.service.ApUserSearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/api/v1/history")
@RestController
@Slf4j
public class ApUserSearchController {

    @Autowired
    private ApUserSearchService apUserSearchService;

    //加载搜索记录
    @RequestMapping("/load")
    public ResponseResult load() {
        return apUserSearchService.findUserSearch();
    }


    @PostMapping("/del")
    public ResponseResult insert(@RequestBody HistorySearchDto dto) {
        log.info("删除搜索记录:{}", dto);
        return apUserSearchService.delUserSearch(dto);
    }
}
